package com.ziq.zcamp.extension

import android.view.View
import com.zhpan.bannerview.BannerViewPager
import com.zhpan.bannerview.BannerViewPager2

fun BannerViewPager<Any>.pageClick(listener: (clickedView : View, position : Int) -> Unit) {
    val minTime = 500L
    var lastTime = 0L
    this.setOnPageClickListener { clickedView, position ->
        val tmpTime = System.currentTimeMillis()
        if (tmpTime - lastTime > minTime) {
            lastTime = tmpTime
            listener.invoke(clickedView, position)
        } else {
        }
    }
}

fun BannerViewPager2<Any>.pageClick(listener: (clickedView : View, position : Int) -> Unit) {
    val minTime = 500L
    var lastTime = 0L
    this.setOnPageClickListener { clickedView, position ->
        val tmpTime = System.currentTimeMillis()
        if (tmpTime - lastTime > minTime) {
            lastTime = tmpTime
            listener.invoke(clickedView, position)
        } else {
        }
    }
}
